export const hasOwnProperty = Object.prototype.hasOwnProperty;

export const toString = Object.prototype.toString;

/* eslint-disable no-bitwise */
const S4 = () => (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
/* eslint-enable no-void */

export function uuid (prefix) {
	const id = S4() + S4() + S4() + S4() + S4() + S4() + S4() + S4();
	return prefix ? prefix + id : id;
}

export function trim (str) {
	return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
}

export const types = {
	/* eslint-disable no-void */
	isUndefined: (obj) => (obj === void 0)
	/* eslint-enable no-void */
};

['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error', 'Object', 'Array'].forEach((type) => {
	types[`is${type}`] = (o) => (toString.call(o) === `[object ${type}]`);
});
